package com.cnzz.site1255174697.holder;

import android.app.Activity;
import android.graphics.Paint;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.cnzz.site1255174697.R;
import com.cnzz.site1255174697.model.MallEntity;
import com.cnzz.site1255174697.utils.AlibcTradeUtils;
import com.cqyanyu.yanyu.view.recyclerView.YViewHolder;
import com.facebook.drawee.view.SimpleDraweeView;

/**
 */
public class GoodsListHolder extends YViewHolder<MallEntity.DataBean.ResultsBean.AitaobaoItemBean> {

    protected SimpleDraweeView imageGoods;
    protected TextView tvGoodsName;
    protected TextView tvPrice;
    protected TextView tvCostPrice;
    protected TextView tvPayNum;
    private MallEntity.DataBean.ResultsBean.AitaobaoItemBean aitaobaoItemBean;

    public GoodsListHolder(View paramView) {
        super(LayoutInflater.from(paramView.getContext()).inflate(R.layout.item_mall_list, null));
        imageGoods = (SimpleDraweeView) itemView.findViewById(R.id.image_goods);
        tvGoodsName = (TextView) itemView.findViewById(R.id.tv_goodsName);
        tvPrice = (TextView) itemView.findViewById(R.id.tv_price);
        tvCostPrice = (TextView) itemView.findViewById(R.id.tv_cost_price);
        tvPayNum = (TextView) itemView.findViewById(R.id.tv_pay_num);
    }

    @Override
    public void onBindViewHolder(MallEntity.DataBean.ResultsBean.AitaobaoItemBean itemData) {
        super.onBindViewHolder(itemData);
        aitaobaoItemBean = itemData;
        imageGoods.setImageURI(itemData.getPict_url());
        tvGoodsName.setText(itemData.getTitle());
        tvPayNum.setText(itemData.getVolume() + "已售出");
        if (!TextUtils.isEmpty(itemData.getZk_final_price()) && !TextUtils.isEmpty(itemData.getReserve_price())) {
            tvPrice.setText(itemData.getZk_final_price());
            tvCostPrice.setText(itemData.getReserve_price());
            tvCostPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            tvPrice.setText(itemData.getReserve_price());
        }
    }

    public void onClick(View paramView) {
        super.onClick(paramView);
        AlibcTradeUtils.showItemId((Activity) this.mContext, this.aitaobaoItemBean.getNum_iid());
    }
}
